/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.frm.bpm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

/**
 *
 * @author Yuwei
 */
@Entity
public class CustomerPaymentRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String customerPaymentRecordId;
    private Timestamp paymentDate;
    private String paymentMethod;
    private String paymentReference;
    private Double paymentAmount;
    private Double amountDue;
    private Boolean cashInAdvance;
    private Boolean refunded;//true: refunded. false: not refunded
    private Boolean realPayment;//true: became real payment after shipped. false: cash in advance, cannot refunded
    @OneToOne(targetEntity = Invoice.class, cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customerPaymentRecord")
    private Invoice invoice;
    
    public CustomerPaymentRecord(){
        customerPaymentRecordId = "";  
        cashInAdvance = true;
        paymentMethod = "";
        amountDue = 0.0;
        paymentAmount = (double)0;
        invoice = null;
        paymentDate = new Timestamp(System.currentTimeMillis());
        paymentReference = "";
        refunded = false;
        realPayment = false;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Boolean getRefunded() {
        return refunded;
    }

    public void setRefunded(Boolean refunded) {
        this.refunded = refunded;
    }

    public Boolean getRealPayment() {
        return realPayment;
    }

    public void setRealPayment(Boolean realPayment) {
        this.realPayment = realPayment;
    }
    
    public Boolean getCashInAdvance() {
        return cashInAdvance;
    }

    public void setCashInAdvance(Boolean cashInAdvance) {
        this.cashInAdvance = cashInAdvance;
    }
    
    public String getCustomerPaymentRecordId() {
        return customerPaymentRecordId;
    }

    public void setCustomerPaymentRecordId(String customerPaymentRecordId) {
        this.customerPaymentRecordId = customerPaymentRecordId;
    }

    public Invoice getInvoice() {
        return invoice;
    }

    public void setInvoice(Invoice invoice) {
        this.invoice = invoice;
    }


    public Double getAmountDue() {
        return amountDue;
    }

    public void setAmountDue(Double amountDue) {
        this.amountDue = amountDue;
    }
    

    public Double getPaymentAmount() {
        return paymentAmount;
    }

    public void setPaymentAmount(Double paymentAmount) {
        this.paymentAmount = paymentAmount;
    }

    public Timestamp getPaymentDate() {
        return paymentDate;
    }

    public void setPaymentDate(Timestamp paymentDate) {
        this.paymentDate = paymentDate;
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public String getPaymentReference() {
        return paymentReference;
    }

    public void setPaymentReference(String paymentReference) {
        this.paymentReference = paymentReference;
    }


    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof CustomerPaymentRecord)) {
            return false;
        }
        CustomerPaymentRecord other = (CustomerPaymentRecord) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.frm.bpm.entity.CustomerPaymentRecord[ id=" + id + " ]";
    }
    
}
